import tushare as ts


token = "cced2019e89426b1dd55bfcdd5a90b3349aa6044c4308a55dc10e31e"
ts.set_token(token)

pro = ts.pro_api()
stock = "002212.SZ"
data = pro.daily(ts_code=stock, start_date="20241027", end_date="20241028")
print(data.tail(10))
df = ts.realtime_tick(ts_code=stock)
df = ts.realtime_quote(ts_code=stock, src="sina")       # sina(新浪) | dc(东方财富)


# 对成交数据进行
def parse_shop_data(record):
    prices = [f"a{i + 1}_p" for i in range(5)][::-1]
    prices += [f"b{i + 1}_p" for i in range(5)]
    nums = [item.replace("_p", "_v") for item in prices]

    return record[prices], record[nums]


def check_point(record):
    a_point, b_point = 0, 0
    return a_point, b_point


code = "002212"
stock = f"{code}.SZ"
df = ts.get_realtime_quotes(code)
p_df, v_df = parse_shop_data(df)